package pl.cvplus.entity;

import javax.persistence.Basic;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.ManyToOne;

/**
 * Created by IntelliJ IDEA.
 * User: Piotrek
 * Date: 02.03.12
 * Time: 23:16
 * To change this template use File | Settings | File Templates.
 */
@javax.persistence.Table(name = "cp_company_data", schema = "public", catalog = "")
@Entity
public class CpCompanyData {
    private Integer id;

    @javax.persistence.Column(name = "id", nullable = false, insertable = true, updatable = true, length = 10, precision = 0)
    @Id
    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    private String companyName;

    @javax.persistence.Column(name = "company_name", nullable = true, insertable = true, updatable = true, length = 100, precision = 0)
    @Basic
    public String getCompanyName() {
        return companyName;
    }

    public void setCompanyName(String companyName) {
        this.companyName = companyName;
    }

    private String nip;

    @javax.persistence.Column(name = "nip", nullable = true, insertable = true, updatable = true, length = 10, precision = 0)
    @Basic
    public String getNip() {
        return nip;
    }

    public void setNip(String nip) {
        this.nip = nip;
    }

    private String adress;

    @javax.persistence.Column(name = "adress", nullable = true, insertable = true, updatable = true, length = 100, precision = 0)
    @Basic
    public String getAdress() {
        return adress;
    }

    public void setAdress(String adress) {
        this.adress = adress;
    }

    private String postalCode;

    @javax.persistence.Column(name = "postal_code", nullable = true, insertable = true, updatable = true, length = 6, precision = 0)
    @Basic
    public String getPostalCode() {
        return postalCode;
    }

    public void setPostalCode(String postalCode) {
        this.postalCode = postalCode;
    }

    private String city;

    @javax.persistence.Column(name = "city", nullable = true, insertable = true, updatable = true, length = 50, precision = 0)
    @Basic
    public String getCity() {
        return city;
    }

    public void setCity(String city) {
        this.city = city;
    }

    private Integer operatorFk;

    @javax.persistence.Column(name = "operator_fk", nullable = false, insertable = true, updatable = true, length = 10, precision = 0)
    @Basic
    public Integer getOperatorFk() {
        return operatorFk;
    }

    public void setOperatorFk(Integer operatorFk) {
        this.operatorFk = operatorFk;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        CpCompanyData that = (CpCompanyData) o;

        if (adress != null ? !adress.equals(that.adress) : that.adress != null) return false;
        if (city != null ? !city.equals(that.city) : that.city != null) return false;
        if (companyName != null ? !companyName.equals(that.companyName) : that.companyName != null) return false;
        if (id != null ? !id.equals(that.id) : that.id != null) return false;
        if (nip != null ? !nip.equals(that.nip) : that.nip != null) return false;
        if (operatorFk != null ? !operatorFk.equals(that.operatorFk) : that.operatorFk != null) return false;
        if (postalCode != null ? !postalCode.equals(that.postalCode) : that.postalCode != null) return false;

        return true;
    }

    @Override
    public int hashCode() {
        int result = id != null ? id.hashCode() : 0;
        result = 31 * result + (companyName != null ? companyName.hashCode() : 0);
        result = 31 * result + (nip != null ? nip.hashCode() : 0);
        result = 31 * result + (adress != null ? adress.hashCode() : 0);
        result = 31 * result + (postalCode != null ? postalCode.hashCode() : 0);
        result = 31 * result + (city != null ? city.hashCode() : 0);
        result = 31 * result + (operatorFk != null ? operatorFk.hashCode() : 0);
        return result;
    }

    private CpPersonalData cpPersonalDataByOperatorFk;

    @ManyToOne
    public
    @javax.persistence.JoinColumn(name = "operator_fk", referencedColumnName = "id", nullable = false)
    CpPersonalData getCpPersonalDataByOperatorFk() {
        return cpPersonalDataByOperatorFk;
    }

    public void setCpPersonalDataByOperatorFk(CpPersonalData cpPersonalDataByOperatorFk) {
        this.cpPersonalDataByOperatorFk = cpPersonalDataByOperatorFk;
    }
}
